const path = require("path");
const {{pascalCase name}} = require("../index");
const {
  getTriggerHelpers,
  getContext,
  getWorkflow,
  formatRequest,
} = require("actionsflow-core");

test("{{snakeCase name}} with webhook", async () => {
  const triggerConstructorParams = await getTriggerConstructorParams({
    name: "{{snakeCase name}}",
    cwd: path.resolve(__dirname, "fixtures"),
    workflowPath: path.resolve(__dirname, "fixtures/workflows/workflow.yml"),
    options: {
      url: "https://{{snakeCase name}}.com/r/news/",
    }
  });
  const {{snakeCase name}} = new {{pascalCase name}}(triggerConstructorParams);

  const requestPayload = formatRequest({
    path: "/",
    body: {
    },
    method: "POST",
    headers: {},
  });
  const request = {
    ...requestPayload,
    params: {},
  };
  const triggerResults = {{snakeCase name}}.webhooks[0].handler.bind({{snakeCase name}})(request);
  expect(triggerResults.length).toBe(1);
  expect(triggerResults[0].action.type).toBe("createCard");
});
